package HP.p0828;

import java.sql.*;

public class SqlTest {
    public static void main(String[] args) throws Exception {
       /* SqlTest sqlTest = new SqlTest();
        sqlTest.select();*/
        new SqlTest().select();
    }

    public void Insert() throws Exception {
        //String url = "jdbc:o"

    }

    public void select() throws Exception {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        String url = "jdbc:oracle:thin:127.0.0.1:1521:orcl";
        String uname = "system";
        String upwd = "123456";
        Connection conn = DriverManager.getConnection(url, uname, upwd);
        String sql = "select * from BM_USER";
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(sql);
        while (rs.next()) {
            System.out.println(rs.getObject("userid"));
            System.out.println(rs.getObject("username"));
            System.out.println(rs.getObject("userpwd"));
        }
        rs.close();
        st.close();
    }

    public void select1() throws ClassNotFoundException, SQLException {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        String url = "jdbc:oracle:thin:127.0.0.1:1521:orcl";
        String uname = "system";
        String upwd = "123456";
        String sql = "select * from user";
        Connection conn = DriverManager.getConnection(url, uname, upwd);
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(sql);
        while (rs.next()) {
            rs.getObject("userid");
            rs.getObject("username");
            rs.getObject("userpwd");
        }
    }

}
